﻿using System;
using System.Collections;
using System.Reflection;
using YAPL.Util;
using Xunit;

namespace YAPL.Test.YAPL.Util {

	public class ReflectionExtensionsTest {

		[Fact]
		public void GetIndexerSetMethodShouldWorkCorrectly() {
			MethodInfo setter = null;
			Assert.DoesNotThrow(() => setter = typeof (ArrayList).GetIndexerSetMethod(new Type[] {typeof (int)}));
			Assert.NotNull(setter);
			Assert.Equal(setter.Name,"set_Item");
			var methodParams = setter.GetParameters();
			Assert.Equal(methodParams.Length, 2);
		}


		[Fact]
		public void GetIndexerGetMethodShouldWorkCorrectly() {
			MethodInfo getter = null;
			Assert.DoesNotThrow(() => getter = typeof(ArrayList).GetIndexerGetMethod(new Type[] { typeof(int) }));
			Assert.NotNull(getter);
			Assert.Equal(getter.Name, "get_Item");
			var methodParams = getter.GetParameters();
			Assert.Equal(methodParams.Length, 1);
		}
	}
}
